package co.yeye.test;

import android.os.Handler;
import android.view.View;
import android.widget.Button;

import models.UserObject;

/**
 * Created by yeye on 15/2/19.
 */
public class Constance {

    public static int SINGLE_REQUEST_ITEM_NUM = 10;     // 单次请求的item数量
    public static int NETWORK_INVALID = 0;
    public static int NETWORK_VALID_WIFI = 1;
    public static int NETWORK_VALID_GPRS = 2;

    public static int DISCOVERY_ITEM_ZHAN = 0;
    public static int DISCOVERY_ITEM_DELETE = 1;

    /**
     * 判断用户是否已登录
     */
    public static boolean isUserLogin(){
        UserObject userObject = MainActivity.getInstance().getUser();
        if(userObject.getName().equals("-1"))
            return false;
        else
            return true;
    }

    /**
     * 配置顶部的按钮
     */
    public static void setTittle( String text , int color , int time , final Button tittle){
        tittle.setText(text);
        tittle.setBackgroundColor(color);
        tittle.setVisibility(View.VISIBLE);

        if(time!=0) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    tittle.setVisibility(View.GONE);
                }
            }, time);
        }
    }

}
